let { getSalespersons, updateSalespersons, deleteSalespersons, getPersonOne, getCustomerList, addSalespersons, getCustomerList1 } = require('../dao/salespersonsDao');
//获取销售员信息
module.exports.getSalespersons = async function () {
    let data = await getSalespersons()
    if (data) {
        return {
            code: 1,
            msg: '获取销售员信息成功',
            data
        }
    }
    return {
        code: 0,
        msg: '获取销售员信息失败'
    }
}
//新增销售员
module.exports.addSalespersons = async function (result) {
    console.log(result);
    let data = await addSalespersons(result)
    if (data) {
        return {
            code: 1,
            msg: '新增成功',
            data
        }
    }
    return {
        code: 0,
        msg: '新增失败'
    }
}

//修改销售员信息
module.exports.updateSalespersons = async function (result) {
    let data = await updateSalespersons(result)
    if (data) {
        return {
            code: 1,
            msg: '修改销售员信息成功',
            data
        }
    }
    return {
        code: 0,
        msg: '修改销售员信息失败'
    }
}

//删除销售员
module.exports.deleteSalespersons = async function (result) {
    let data = await deleteSalespersons(result)
    if (data) {
        return {
            code: 1,
            msg: '删除销售员信息成功',
            data
        }
    }
    return {
        code: 0,
        msg: '删除销售员信息失败'
    }
}
//查看该销售员负责的客户列表
module.exports.getCustomerList = async function () {
    let data = await getCustomerList()
    if (data) {
        return {
            code: 1,
            msg: '获取销售员复杂的客户列表成功',
            data
        }
    }
    return {
        code: 0,
        msg: '获取销售员复杂的客户列表失败'
    }
}
//查看该销售员负责的客户列表List
module.exports.getCustomerList1 = async function (result) {
    let data = await getCustomerList1(result)
    if (data.length > 0) {
        return {
            code: 1,
            msg: '获取销售员负责的客户列表成功',
            data
        }
    }
    return {
        code: 0,
        msg: '获取销售员负责的客户列表失败',
        data
    }
}

//获取某一个销售员的信息
module.exports.getPersonOne = async function (result) {
    let data = await getPersonOne(result)
    if (data) {
        return {
            code: 1,
            msg: '获取某个销售员的信息成功',
            data
        }
    }
}
